//
//  SelectTheCertificationViewController.m
//  HAODE
//
//  Created by panquanReabam.com on 15/9/15.
//  Copyright (c) 2015年 reabam.com. All rights reserved.
//

#import "SelectTheCertificationViewController.h"
#import "SubmitCompanyAuthInfoViewController.h"
#import "RDVTabBarController.h"
#import "MyViewController.h"
#import "HAODEsingleton.h"
#import "DailyTableViewCell.h"
#import "TheLoginViewController.h"

#import "SubmitUserAuthInfoViewController.h"
@interface SelectTheCertificationViewController ()<UITableViewDataSource,UITableViewDelegate,UIScrollViewDelegate, UITextViewDelegate,UIImagePickerControllerDelegate,UIAlertViewDelegate,UIGestureRecognizerDelegate,UINavigationControllerDelegate,UIActionSheetDelegate>
{
    
    NSArray *array;
    NSArray *array1;
    NSArray *array2;
    UIButton *noticeCountBtn;
    UIWebView *web;
    UIButton* name1;
    UIButton* name;
    HAODEsingleton* commdity;
    UIButton *imageView ;
    UIView *headerView;
    UIButton* renzhenButton;
}

@end

@implementation SelectTheCertificationViewController

- (void)viewDidDisappear:(BOOL)animated

{
    
    [super viewDidDisappear:animated];
    
    
    self.navigationController.delegate = nil;
    
 
    
}
-(void)BackAction:(UIButton *)sender{
    
     [self.navigationController popToViewController:[self.navigationController.viewControllers objectAtIndex:0] animated:YES];
}

-(void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    
    self.navigationController.delegate = self;
    self.navigationController.interactivePopGestureRecognizer.enabled = YES;
    self.navigationController.interactivePopGestureRecognizer.delegate = self;
    [self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@""] forBarMetrics:UIBarMetricsDefault];
    self.navigationController.navigationBar.shadowImage =[[UIImage alloc] init];
    
    [[self rdv_tabBarController] setTabBarHidden:YES];
    self.navigationController.navigationBarHidden = NO;
        self.navigationController.navigationBar.barStyle = UIBaselineAdjustmentNone;
    UILabel *lineLabel=[[UILabel alloc] initWithFrame:CGRectMake(0, 43,ScreenWidth, 1)];
    [lineLabel setBackgroundColor:[UIColor colorWithRed:238.0/255.0 green:238.0/255.0 blue:238.0/255.0 alpha:1.0]];
    [self.navigationController.navigationBar addSubview:lineLabel];
    [self.navigationController.navigationBar setTintColor:[UIColor whiteColor]];
    [[UINavigationBar appearance] setBarTintColor:Color];
    
    UIImage* backImage = [UIImage imageNamed:@"fanhui"];
    CGRect backframe = CGRectMake(0,0,30,30);
    UIButton* backButton= [[UIButton alloc] initWithFrame:backframe];
    [backButton setBackgroundImage:backImage forState:UIControlStateNormal];
    backButton.titleLabel.textAlignment=NSTextAlignmentLeft;
    [backButton addTarget:self action:@selector(BackAction:) forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem* leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:backButton];
    self.navigationItem.leftBarButtonItem = leftBarButtonItem;
        
}
- (void)viewDidLoad
{
    [super viewDidLoad];
    [self loadViewTabel];
    
    [self tableHeadView];
    
    self.title = @"选择认证方式";
    
    [self.navigationController.navigationBar setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:
                                                                     backColor,
                                                                     UITextAttributeTextColor,
                                                                     [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:1],
                                                                     UITextAttributeTextShadowColor,
                                                                     [NSValue valueWithUIOffset:UIOffsetMake(0, 0)],
                                                                     UITextAttributeTextShadowOffset,
                                                                     [UIFont fontWithName:@"Helvetica Neue" size:tetlefot],
                                                                     UITextAttributeFont,nil]];
    
    
}

- (void)loadViewTabel{
    
    
    array = @[@"店主授权认证"];
    array1 = @[@"新增认证门店"];
    array2 = @[@"(店长/导购)",@"(店主)"];
}


- (void)tableHeadView
{
      _table.separatorStyle=UITableViewCellSeparatorStyleNone;
    _table.backgroundColor=zuiqianhuicolor;
    _table.frame=CGRectMake(0, -20, ScreenWidth, ScreenHeight-64-49);
  
}




#pragma mark--TableViewDelegate
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 2 ;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    if (section == 0) {
        return array.count;
    }
        return array1.count;
    
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"Cell";
    
    DailyTableViewCell* cell = (DailyTableViewCell*)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil)
    {
        NSArray* nib = [[NSBundle mainBundle] loadNibNamed:@"DailyTableViewCell" owner:self options:nil];
        cell = [nib objectAtIndex:0];
    }
    

    if (indexPath.section == 0) {
       cell.textLabel.text = [array objectAtIndex:indexPath.row] ;
        UILabel* label=[[UILabel alloc]initWithFrame:CGRectMake(cell.textLabel.width+145, 25, 180, 17) ];
       label .text = [array2 objectAtIndex:0];
       label.textColor=luseColor;
      [cell.contentView addSubview:label];
        
    }
    if (indexPath.section == 1) {
        cell.textLabel.text = [array1 objectAtIndex:indexPath.row] ;
        UILabel* label=[[UILabel alloc]initWithFrame:CGRectMake(cell.textLabel.width+125, 25, 180, 17) ];
        label .text = [array2 objectAtIndex:1];
        label.textColor=luseColor;
        [cell.contentView addSubview:label];
    }

    
    
    
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    DailyTableViewCell *cell =(DailyTableViewCell *)[tableView cellForRowAtIndexPath:indexPath];
    
    if ([cell.textLabel.text isEqualToString:@"店主授权认证"]) {
        
        SubmitUserAuthInfoViewController * Login=[[SubmitUserAuthInfoViewController alloc]init];
        
        [self.navigationController pushViewController:Login animated:YES];
        
    }else if ([cell.textLabel.text isEqualToString:@"新增认证门店"]) {
        
        SubmitCompanyAuthInfoViewController * Login=[[SubmitCompanyAuthInfoViewController alloc]init];
        
        [self.navigationController pushViewController:Login animated:YES];
    }
    
    
}
- (CGFloat) tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    return  130/2;
}


- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return 10;
}

@end